package com.xcm.service.impl;

import com.google.common.collect.Lists;
import com.xcm.dao.ProgramBottomMapper;
import com.xcm.model.TbProgramBottom;
import com.xcm.model.dto.BottomProgramDTO;
import com.xcm.service.ProgramBottomService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 下屏节目实现类
 */
@Service(value = "programBottomService")
public class ProgramBottomServiceImpl implements ProgramBottomService {

	@Autowired
	private ProgramBottomMapper programBottomMapper;

	/**
	 * 批量保存上屏节目
	 * @param programBottomList   List<TbProgramBottom>类型对象
	 */
	@Override
	@Transactional(readOnly = false, rollbackFor = Exception.class)
	public void saveProgramBottomBatch(List<TbProgramBottom> programBottomList) {
		programBottomMapper.saveProgramBottomBatch(programBottomList);
	}

	/**
	 * 通过xc版本查找下屏节目列表
	 * @param xcVersion xc版本
	 * @param bottom 下屏节目
	 * @return  List<TbProgramBottom>
	 */
	@Override
	public List<TbProgramBottom> listProgramBottomByXcVersion(String xcVersion, String bottom) {
		return programBottomMapper.listProgramBottomByXcVersion(xcVersion, bottom);
	}

	/**
	 * 通过xc版本获取下屏节目DTO列表
	 *
	 * @param xcVersion xc版本
	 * @return List<BottomProgramDTO>
	 */
	@Override
	public List<BottomProgramDTO> listBottomProgramDTOByXcVersion(String xcVersion) {
		if (StringUtils.isBlank(xcVersion)) {
			return Lists.newArrayList();
		}
		return programBottomMapper.listBottomProgramDTOByXcVersion(xcVersion);
	}
}
